/**
 * 
 */
package net.microlinktech.testing.ui.event;

import java.util.Random;

import net.microlinktech.testing.bean.Meter;

/**
 * @author zhangqing
 *
 */
public class MeterEvent {
	
	private static final int A_BASE = 10;
	private Random random;
	
	public MeterEvent(){
		random = new Random();
	}
	
	public Meter createMeter() {

		float temperatureVal = 10 + random.nextFloat() * 10;
		float phVal = (float) (A_BASE + random.nextFloat() * 0.3);
		float humidityVal = 10 + random.nextFloat() * 10;
		float carbonVal = (float) (A_BASE + random.nextFloat() * 0.3);
		float soilDensity = 10 + random.nextFloat() * 10;


		Meter meter = new Meter(temperatureVal, humidityVal, phVal, carbonVal, soilDensity);
		return meter;
	}

	public Meter updateMeter(Meter meter) {
		float temperatureVal = 10 + random.nextFloat() * 10;
		float phVal = (float) (A_BASE + random.nextFloat() * 0.3);
		float humidityVal = 10 + random.nextFloat() * 10;
		float carbonVal = (float) (A_BASE + random.nextFloat() * 0.3);
		float soilDensity = 10 + random.nextFloat() * 10;


		meter.setTemperatureVal(temperatureVal);
		meter.setHumidityVal(humidityVal);
		meter.setPhVal(phVal);
		meter.setCarbonVal(carbonVal);
		meter.setSoilDensity(soilDensity);


		return meter;
	}

}
